[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
Text Text Files File Type
The predefined file type Text is roughly (but not exactly) equivalent
to "file of Char". It is used with ASCII text files that can be read
in as if from the keyboard and can be written to as if to the screen.
In reading from a text file, Read and Readln will automatically
convert from ASCII text to Integer, Byte, Real, Char, and string.
Likewise, when writing out to a text file, Write and Writeln will
automatically convert from Integer, Byte, Real, Char, Boolean, and
string to ASCII text.
Text files are made up of lines of text terminated by end-of-line
markers. The file is terminated with an end-of-file marker. Text files
can only be processed sequentially, and simultaneous input and output
is not allowed. When a newly created text file is closed, an end-of-
file marker is automatically appended to the end of the file.
Turbo Pascal allows the defining of the buffer size to be used with
Text files. By default, the buffer size is 128 bytes. The following
statement will declare a text file variable with a buffer size of 4K
bytes:
var
TFile : Text [$1000];
The example below opens the text file MYFILE.TXT and displays its
contents on the screen.
-------------------------------- Example ---------------------------------
var
InFile : text;
Line : string[80];
begin
Assign(InFile,'MYFILE.TXT');
Reset(InFile);
while not EOF(InFile) do begin
Readln(Infile,Line);
Writeln(Line)
end;
Close(InFile)
end.
See Also:
files
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson